<template>
  <div class="container">
    <view class="cell" v-for="(item,index) in list" :key="index">
      <view class="title fz12">{{item.name}}</view>
      <view class="box">
        <uv-cell-group :border="false">
          <uv-cell :title="value.label" :border="false" v-for="(value,idx) in item.fieldName" :key="idx">
            <template v-slot:value>
              <uv-switch asyncChange v-model="value.value" @change="changeSwitch(value)" activeColor="#9E06FF" size="18"></uv-switch>
            </template>
          </uv-cell>
        </uv-cell-group>
      </view>
    </view>
  </div>
</template>

<script setup lang="ts">
const { proxy } = getCurrentInstance();
import useCounterStore from "@/stores/counter";
const counter = useCounterStore();
let value = ref(false);
let list = ref([]);

onShow(() => {
  getInfo();
});

async function getInfo() {
  list.value = await proxy.$apis.selectAll();
  console.log("你是真不行", list.value);
}

async function changeSwitch(e) {
  console.log(e);
  await proxy.$apis.updateById({ id: e.id, value: !e.value });
  proxy.$utils.showToast("修改成功");
  getInfo();
}
</script>



<style lang="scss" scoped>
.container {
  min-height: 100vh;
  background-color: #fafafa;
  .title {
    padding: 16px;
  }
  .box {
    background-color: white;
  }
}
</style>





